#include<iostream>
using namespace std;

char* getf(char* arr, int n = 1);

int main()
{
	const int Size = 20;
	char arr[Size]{};
	cout << "enter a string:";
	cin.getline(arr,Size);
	char* ps = getf(arr, 4);
	cout << ps << endl;
	delete [] ps;
	ps = getf(arr);
	cout << ps << endl;
	delete [] ps;
	return 0;
}

char* getf(char* arr, int n)
{
	if (n < 0)
		n = 0;
	char* ps = new char[n + 1];
	int i = 0;
	for (i = 0; i < n && arr[i]; i++)
		ps[i] = arr[i];
	while (i <= n)
	{
		ps[i] = 0;
		i++;
	}
	return ps;
}
